-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config: Add the read_only
setting
#65
base: master
Are you sure you want to change the base?
Conversation
c5a324e
to
c7aed7c
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #65 +/- ##
==========================================
+ Coverage 93.39% 93.44% +0.05%
==========================================
Files 28 29 +1
Lines 999 1022 +23
==========================================
+ Hits 933 955 +22
- Misses 66 67 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@giovannipizzi @eimrek This would be a possible implementation to allow easily making an instance of the API fully read-only. |
Heya, how do other fastapi packages achieve this? Is there any documentation links? |
I tried googling, but nothing concrete showed up. Might be that I have missed it of course. |
This is the recommended way as per the documentation of `fastapi` as it can be easily made available to routes.
This setting, which is set to `True` by default, will determine whether the instance is to be read-only. The `protected_methods_middleware` function is added as middleware to the application. If the `read_only` setting is `True` and the request method is `DELETE`, `PATCH`, `POST` or `PUT`, a `405 Method Not Allowed` response is returned.
c7aed7c
to
a3535a3
Compare
Fixes #63
This setting, which is set to
True
by default, will determine whetherthe instance is to be read-only. The
protected_methods_middleware
function is added as middleware to the application. If the
read_only
setting is
True
and the request method isDELETE
,PATCH
,POST
orPUT
, a405 Method Not Allowed
response is returned.